package com.luo.controller;

import com.luo.pojo.Role;
import com.luo.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @RequestMapping(value = "/selectRoleList",method = RequestMethod.GET)
    public Map<String,Object> selectRoleList(@RequestParam int page,
                                                   @RequestParam int limit,
                                                   String roleName,
                                                   String roleLevel){
       return roleService.selectRoleList(roleName,roleLevel,page,limit);

    }

    @RequestMapping(value = "/selectRoleNames",method = {RequestMethod.GET,RequestMethod.POST})
    public Map<String,Object> selectRoleNames(){
        return roleService.selectRoleNames();
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> inset(@RequestBody Role role){
        return roleService.insert(role);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Role role){
        return roleService.update(role);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Map<String,Object> delete(Integer id){
        return roleService.delete(id);
    }

}
